<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::table('contract_sign_histories', function (Blueprint $table) {
            $table->foreignId('application_id')
                ->nullable()
                ->after('freelancer_id')
                ->constrained('task_applications')
                ->nullOnDelete();
            $table->string('contract_download_url', 2048)
                ->nullable()
                ->after('status');
            $table->string('contract_file_path', 2048)
                ->nullable()
                ->after('contract_download_url');

        });
    }

    public function down(): void
    {
        Schema::table('contract_sign_histories', function (Blueprint $table) {
            $table->dropForeign(['application_id']);
            $table->dropColumn([
                'application_id',
                'contract_download_url',
                'contract_file_path',
            ]);
        });
    }
};
